import {fetchTableList } from '../api'

export const SET_LIST = 'SET_LIST'
// 异步 action 
export function set_list() {
	// 必须启动 redux-thunk 
	return async (dispatch) => {
		// 请求数据
		const resp = await fetchTableList()
		// 分发action 
		dispatch({ type: SET_LIST, payload: resp.data.data })
	}
}

export const DELETE_LIST = 'DELETE_LIST'

export function delete_list(payload) {
	return { type: DELETE_LIST, payload }
}

// 添加
export const ADD_LIST = 'ADD_LIST'

export function add_list(payload) {
	return { type: ADD_LIST, payload }
}

// 编辑
export const EDIT_LIST = 'EDIT_LIST'

export function edit_list(payload) {
	return { type: EDIT_LIST, payload }
}